<script setup lang="ts">
import Detail from './Components/Detail.vue'
import { ContentDetailWrap } from '@/components/ContentDetailWrap'
import { ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { useRouter, useRoute } from 'vue-router'
import { getProductChaKanApi } from '@/api/product'
import type { ProductData } from '@/api/product/types'

const { push } = useRouter()

const { query } = useRoute()

const { t } = useI18n()

const currentRow = ref<Nullable<ProductData>>(null)

const getTableDet = async () => {
  const res = await getProductChaKanApi(query.product_id as string)
  if (res) {
    currentRow.value = res.data
  }
}

getTableDet()
</script>

<template>
  <ContentDetailWrap :title="t('exampleDemo.detail')" @back="push('/product/processProductList')">
    <Detail :current-row="currentRow" />
  </ContentDetailWrap>
</template>
